/**
 * 
 */
package co.fitstart.entity.course.schedule;

import org.apache.commons.lang3.ArrayUtils;

import com.demo2do.core.utils.Alias;

/**
 * @author downpour
 *
 */
@Alias("scheduleStatus")
public enum ScheduleStatus {
    
    SCHEDULE("schedule", "课程排期中", true),
    
    READY("ready", "已排期", true),
    
    FINISH("finish", "已完成", true),
    
    EXPIRY("expiry", "逾期" , true);
    
    private String alias;
    
    private String description;
    
    private boolean real;
    
    private ScheduleStatus[] realCourseStatus;
    
    /**
     * 
     * @param alias
     * @param description
     */
    ScheduleStatus(String alias, String description, boolean real, ScheduleStatus ... courseStatus) {
        this.alias = alias;
        this.description = description;
        this.real = real;
        this.realCourseStatus = courseStatus;
    }
    
    /**
     * 
     * @param alias
     * @return
     */
    public static ScheduleStatus aliasOf(String alias) {
        for (ScheduleStatus courseStatus : ScheduleStatus.values()) {
            if (courseStatus.getAlias().equalsIgnoreCase(alias)) {
                return courseStatus;
            }
        }
        
        return null;
    }
    
    /**
     * 
     * @return
     */
    public boolean isSchedule() {
        return this.equals(SCHEDULE);
    }
    
    /**
     * 
     * @return
     */
    public boolean isReady() {
        return this.equals(READY);
    }
    
    /**
     * 
     * @return
     */
    public boolean isFinish() {
        return this.equals(FINISH);
    }
    
    /**
     * 
     * @return
     */
    public boolean isExpiry() {
        return this.equals(EXPIRY);
    }
    
    /**
     * @return the alias
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * @return the real
     */
    public boolean isReal() {
        return real;
    }
    
    /**
     * @return the realCourseStatus
     */
    public ScheduleStatus[] getRealCourseStatus() {
        
        if(ArrayUtils.isEmpty(this.realCourseStatus)) {
            return new ScheduleStatus[] { this };
        }
        
        return realCourseStatus;
    }
}
